#ifndef SEMANTICINFOUPDATER_H
#define SEMANTICINFOUPDATER_H

#include "semanticinfo.h"
#include "../js_lib/qmljsscanner.h"

#include <QWaitCondition>
#include <QModelIndex>
#include <QMutex>
#include <QThread>
class SemanticInfoUpdater: public QThread
{
    Q_OBJECT

public:
    SemanticInfoUpdater(QObject *parent = 0);
    virtual ~SemanticInfoUpdater();

    void abort();
    void update(const QmlJS::Document::Ptr &doc, const QmlJS::Snapshot &snapshot);
    void reupdate(const QmlJS::Snapshot &snapshot);

Q_SIGNALS:
    void updated(const SemanticInfo &semanticInfo);

protected:
    virtual void run();

private:
    SemanticInfo makeNewSemanticInfo(const QmlJS::Document::Ptr &doc,
                                                 const QmlJS::Snapshot &snapshot);

private:
    QMutex m_mutex;
    QWaitCondition m_condition;
    bool m_wasCancelled;
    QmlJS::Document::Ptr m_sourceDocument;
    QmlJS::Snapshot m_sourceSnapshot;
    SemanticInfo m_lastSemanticInfo;
};

#endif // SEMANTICINFOUPDATER_H
